// IntroState.cpp: implementation of the IntroState class.
//
//////////////////////////////////////////////////////////////////////

#include "IntroState.h"

#ifdef FREEGLUT_IS_PRESENT
#  include <GL/freeglut.h>
#else
#  ifdef __APPLE__
#    include <GLUT/glut.h>
#  else
#    include <GL/glut.h>
#  endif
#endif

/* Application Includes*/
#include "Controller.h"
#include "BackGroundImage.h"
#include "BlinkingImage.h"
#include "Keyboard.h"
#include "SplashScreenState.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

IntroState::IntroState()
{
glClearColor(1.0f,0.0f,0.0f,1.0f);  
this->kb = new Keyboard(); 
this->backgroundImage = new BackGroundImage("./IntroState.bmp");
this->blinkingImage = new BlinkingImage("./IntroWait.bmp",eAlphaKey_RED,0.1f,0.1f,0.8f,0.10f,0.7f);
}

IntroState::~IntroState()
{
delete kb;
delete backgroundImage;
delete blinkingImage;
}

void IntroState::load(const char* filename)
{
	
}

void IntroState::display(void)
{
this->backgroundImage->display();
this->blinkingImage->display();}

void IntroState::resize(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0, (GLfloat) w/(GLfloat) h, 0.0, 30.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void IntroState::keyUp(unsigned char key, int x, int y)
{
kb->read(key,PW_UP,x,y);
}

void IntroState::keyDown(unsigned char key, int x, int y)
{
kb->read(key,PW_DOWN,x,y);
}

void IntroState::specialUp(int key, int x, int y)
{

}

void IntroState::specialDown(int key, int x, int y)
{

}

void IntroState::motion(int newx, int newy)
{

}

void IntroState::passive(int newx, int newy)
{

}

void IntroState::mouse(int button, int state, int mouseX, int mouseY)
{

}

State* IntroState::idle(void)
{
if(this->kb->isPressed(27))
    {
    exit(0);
    }
else if(this->kb->isPressedAny())
    {
    return (State*) new SplashScreenState();
    }
else
    {
    return this;
    }
}

